<script lang="ts" setup>
import { useRouter } from 'vue-router'

const router = useRouter()

const back = () => {
  router.back()
}

const backHome = () => {
  router.replace('/home')
}

const dark = JSON.parse(localStorage.getItem('option') as any)?.themeSwitch
</script>

<template>
  <div class="error-container">
    <div class="error-info">
      <p
        class="error-info-text"
        :style="{ color: dark ? '#e5e5e5' : '#303030' }"
      >
        页面访问错误
      </p>
      <svg class="icon" aria-hidden="true" v-if="!dark">
        <use xlink:href="#icon-404"></use>
      </svg>
      <svg class="icon" aria-hidden="true" v-else>
        <use xlink:href="#icon-icon-404-2"></use>
      </svg>
    </div>
    <div class="back">
      <el-button type="warning" plain @click="back">返回上一页</el-button>
      <el-button type="primary" plain @click="backHome">返回首页</el-button>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.error-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  .error-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 3.125rem;
    .error-info-text {
      font-size: 2.5rem;
      font-weight: bold;
    }
    .icon {
      font-size: 400px;
    }
  }
}
</style>
